package com.fzg.controller;


import com.fzg.common.enums.ResponseWrapper;
import com.fzg.common.model.message.param.*;
import com.fzg.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 留言表 前端控制器
 * </p>
 *
 * @author fzg
 * @since 2021-12-13
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    /**
     * 查询当前用户的所有消息
     */
    @GetMapping("/queryAllMessage")
    public ResponseWrapper queryAllMessage(QueryAllMessage param){
        return messageService.queryAllMessage(param);
    }

    /**
     * 得到每个用户或每个公司的消息列表
     */
    @GetMapping("/getMessageList")
    public ResponseWrapper getMessageList(QueryAllMessage param){
        return messageService.getMessageList(param);
    }

    /**
     * 打开抽屉将未读消息变为已读
     */
    @PostMapping("/changeUnRead")
    public ResponseWrapper changeUnRead(@RequestBody ChangeUnRead param){
        return messageService.changeUnRead(param);
    }

    /**
     * 根据messageAid和当前登陆人或公司账号查询对应的消息列表
     */
    @GetMapping("/getMessageByMessageAid")
    public ResponseWrapper getMessageByMessageAid(MessageByUserAidAndCompanyAid param){
        return messageService.getMessageByMessageAid(param);
    }

    /**
     * 发送简历（相当于也是发送一条消息）
     */
    @PostMapping("/sendResumeApi")
    public ResponseWrapper sendResume(@RequestBody SendResume param){
        return messageService.sendResume(param);
    }

    /**
     * 发送消息
     */
    @PostMapping("/sendMessage")
    public ResponseWrapper sendMessage(@RequestBody SendMessageParam param){
        return messageService.sendMessage(param);
    }

    /**
     * 插入一条消息（给公司打招呼）
     */
    @PostMapping("/insertMessage")
    public ResponseWrapper insertMessage(@RequestBody InsertMessage param){
        return messageService.insertMessage(param);
    }

    /**
     * 撤回消息
     */
    @PostMapping("/withdrawApi")
    public ResponseWrapper withdrawApi(@RequestBody WithdrawApi param){
        return messageService.withdrawApi(param);
    }

    /**
     * 企业去跟用户沟通（给用户打招呼）
     */
    @PostMapping("/companyChatUser")
    public ResponseWrapper companyChatUser(@RequestBody CompanyChatUser param){
        return messageService.companyChatUser(param);
    }

    /**
     * 判断企业是否与用户沟通过
     */
    @GetMapping("/checkIsChart")
    public ResponseWrapper checkIsChart(CompanyChatUser param){
        return messageService.checkIsChart(param);
    }


}
